<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="utf-8">
    <title>登录--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/image/favicon.ico">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/public.css" media="all"/>
    <link rel="stylesheet" href="/css/drag.css" media="all"/>
    <style>
        html, body {
            width: 100%;
            height: 100%;
        }

        body {
            font-family: "华文细黑";
            background: url("/image/login_bg.jpg") no-repeat;
            background-size: 100%;
        }

        .slidetounlock {
            font-size: 12px;
            background: -webkit-gradient(linear, left top, right top, color-stop(0, #4d4d4d), color-stop(.4, #4d4d4d), color-stop(.5, #fff), color-stop(.6, #4d4d4d), color-stop(1, #4d4d4d));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            -webkit-animation: slidetounlock 3s infinite;
            -webkit-text-size-adjust: none
        }

        @-webkit-keyframes slidetounlock {
            0% {
                background-position: -200px 0
            }
            100% {
                background-position: 200px 0
            }
        }
    </style>
</head>
<body class="loginBody" style="">
<form class="layui-form" action="/valid" method="post">
    <div class="login_face"><img src="/image/login.png" class="userAvatar"></div>
    <div class="layui-form-item input-item">
        <label for="userName">用户名</label>
        <input type="text" placeholder="请输入用户名" id="userName" class="layui-input" lay-verify="required">
    </div>
    <div class="layui-form-item input-item">
        <label for="password">密码</label>
        <input type="password" placeholder="请输入密码" id="password" class="layui-input" lay-verify="required">
    </div>
    <div class="layui-form-item">
        <input type="radio" name="type" value="1" class="layui-input" lay-verify="required" title="客户" checked>
        <input type="radio" name="type" value="2" class="layui-input" lay-verify="required" title="系统管理员">
    </div>
    <div id="wrapper" class="layui-form-item">
        <div id="drag">
            <div class="drag_bg"></div>
            <div class="drag_text slidetounlock" onselectstart="return false;" unselectable="on">请按住滑块，拖动到最右边</div>
            <input type="hidden" name="name">
            <div class="handler handler_bg"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <button class="layui-btn layui-block" lay-filter="login" lay-submit>登录</button>
    </div>
</form>
<script type="text/javascript" src="/plugins/layui/layui.js"></script>
<script type="text/javascript"  src="/js/jquery-1.12.3.js"></script>
<script type="text/javascript" src="/js/drag.js"></script>
<script type="text/javascript">
    //验证码拖动
    $("#drag").drag();
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer
        $ = layui.jquery;

        //登录按钮
        form.on("submit(login)", function (data) {

            $.ajax({
                type: "POST",  //提交方式
                url: "/valid",//路径
                data: {
                    "userName": $("#userName").val(),
                    "password": $("#password").val(),
                    "type": $("input[name='type']:checked").val(),
                },//数据，这里使用的是Json格式进行传输
                dataType: "json", //返回类型为json
                success: function (result) {//返回数据根据结果进行相应的处理
                    if (result.status == "true") {
                        window.location.href = "/index";
                    } else {
                        layer.msg(result.msg);
                    }
                }
            });
            return false;
        })


        //表单输入效果
        $(".loginBody .input-item").click(function (e) {
            e.stopPropagation();
            $(this).addClass("layui-input-focus").find(".layui-input").focus();
        })
        $(".loginBody .layui-form-item .layui-input").focus(function () {
            $(this).parent().addClass("layui-input-focus");
        })
        $(".loginBody .layui-form-item .layui-input").blur(function () {
            $(this).parent().removeClass("layui-input-focus");
            if ($(this).val() != '') {
                $(this).parent().addClass("layui-input-active");
            } else {
                $(this).parent().removeClass("layui-input-active");
            }
        })
    })


</script>
</body>
</html>
